﻿namespace CommLib
{
    public class MessageCalendars : BluetoothMessage
    {
        public MessageCalendars(byte[] data, int length)
            : base(BtMessageType.CalendarList, data, length)
        {
        }

        public AndroidCalendar[] getCalendars()
        {
            AndroidCalendar[] list = null;

            if (mData.Length % AndroidCalendar.FIELD_COUNT == 0)
            {
                list = new AndroidCalendar[mData.Length / AndroidCalendar.FIELD_COUNT];

                int idx = 0;
                for (int i = 0; i < mData.Length; i += AndroidCalendar.FIELD_COUNT)
                {
                    list[idx++] = new AndroidCalendar(mData, i);
                }
            }

            return list;
        }
    }
}
